This invention relates to a data processing system and more particularly to a data processing system capable of performing logical and arithmetic operations on data stored in a main memory, a general purpose register file and/or a stack.
In prior art data processing systems, there are two types of computer architectures; i.e., a stack machine using a stack to perform operations and a register machine using a general purpose register file to perform operations.
A stack machine has a main memory and a stack as its resources and perfomes operations on data stored in the main memory and/or the stack. The stack comprises a plurality of elements, the size of each element being of a fixed word length. One of these elements is pointed by a stack pointer (SP). The element pointed by the SP is called a Top of the Stack (TOS). Writing data from the memory to the stack or reading data from the stack to the memory can only be executed at the TOS mentioned above in accordance with the so called "Last In First Out" (LIFO) principle. Operations on data stored in the stack can only be performed on data in the TOS and data stored in the element next to the TOS.
A register machine has, as its resources, a main memory and a general purpose register file, and performs operations on data stored in the main memory and/or the general purpose register file. The general purpose register file also has a plurality of elements, the size of each element being of a fixed word length.
The characteristics of the stack machine and those of the register machine are complementary, due to the above-mentioned structure of these machines.
The stack machine is advantageous in the field of the evaluation of arithmetical and logical expressions and can easily and efficiently evaluate the expressions. This is because the stack machine dynamically and automatically allocates the main memory, so that only the minimum number of storage locations are used. In addition, although all modern compilers for register machines first (either implicity or explicity) translate any arithmetic or logical expression into reverse-polish notation and then into machine language, compilers for stack machines do not have to perform the second translation, since the reverse-polish notation exactly corresponds to the sequence of the required stack machine instructions.
In contrast to this, the compilers for register machines have to perform the second translation from reverse-polish notation into the required register machine instructions. The optimization during the second translation depends on the architecture such as the number of the elements of the register file so that efficient generation of machine language is difficult.
The stack machine is also suitable for program sequence control, for example a dynamic reservation of a temporary area and a dynamic release of the reserved temporary area, and a call operation of a subprogram or a program interrupt. This is because the stack machine does not need to prereserve any area for a program to be called and can store the called program into the stack at any required moment during a dynamic allocation, and because the contents stored in the stack are not destroyed upon writing. In contrast, the register machine is not suitable for program sequence control, since the register machine needs to reserve storage areas for dynamic allocation, and the contents stored in the register are destroyed upon writing.
However, the stack machine generally has the following disadvantages. The first disadvantage is that the number of steps for performing an operation in the stack machine is greater than that in the register machine. For example, if an operation for adding the data A and B stored in the memory is performed, the stack machine requires three steps; i.e., PUSH A, PUSH B and ADD, whereas the register machine requires no more than two steps; i.e., LOAD A, ADD B. The second disadvantage of the stack machine is that the operating speeds are very low compared to the register machine. This is because the stack machine is equivalent to a machine having only one accumulator, since operations on data stored in the stack can only be performed between data stored in the TOS and data stored in the element next to the TOS, as described above. In contrast with the stack machine, the register machine is able to rapidly access any element in the general purpose register file, and therefore the operating speeds are very high compared to the stack machine. Thus, the architecture which is most suitable for operation and addressing is the register machine rather than the stack machine.
In the prior art, the stack machine and the register machine have different architectures having complementary characteristics as mentioned above. In the stack machine, there can be three types of transfer instructions, as follows: ##EQU1## and one type of dyadic operation instruction, as follows: EQU .uparw.TOS.multidot..uparw.TOS.fwdarw..dwnarw.TOS
where (and hereinafter,) M.sub.i and M.sub.j are operands of the i-th and j-th elements, respectively, in the main memory, .dwnarw.TOS denotes the push down operation into the stack, .uparw.TOS denotes the pop up operation from the stack, and the dots between operands in the dyadic operation instructions denote arithmetic or logical operations. In the register machine, there can be four types of transfer instructions, as follows: ##EQU2## EQU M.sub.1 .rarw.M.sub.j
and six types of dyadic operation instructions, as follows: ##EQU3## where and hereinafter, R.sub.i, R.sub.j and R.sub.k are operands of i-th, j-th and k-th elements, respectively, in the general purpose register file. Both machines have instructions of two-address format.
Now, consider a "composite" machine made by simply combining the stack machine and register machine which will have the advantages of both the stack machine and the register machine. The "composite" machine must have three resources; i.e., a main memory, a general purpose register file and a stack.
In order to utilize these resources effectively, a large number of instructions may be required as follows. There may be twelve transfer instructions required, as follows: ##EQU4## and there may be thirty two (8.times.4) dyadic operation instructions, as follows: ##EQU5## where the expression "TOS" without an arrow means the top of the stack when the stack is utilized as a usual register without stack operation. Thus, in the "composite" machine made by combining the register machine and the stack machine, the number of instructions is greater than that required in the register machine alone or the stack machine alone. In addition the number of the locations for storing the results of operations is increased. Further, the "composite" machine has the disadvantages of a complicated instruction set an increased memory area (since the instruction format is either a three-address format or both two-address and three-address formats), and the size of the instruction is increased. Therefore, the throughput of the "composite" machine is low and the "composite" machine is not adaptable to practical use.